<?php
/**
 * Created by PhpStorm.
 * User: adim
 * Date: 2016/8/7
 * Time: 23:22
 */
    global $_W,$_GPC;
    $id = $_GPC['id'];
    $member = m('member')->getMember($id);
    $years = array();
    $current_year = date('Y');
    $year = $_GPC['year'];
    $month = $_GPC['month'];
    for ($i = $current_year - 10; $i <= $current_year; $i++) {
        $years[] = array('data' => $i, 'selected' => $i == $year);
    }
    $months = array();
    $current_month = date('m');
    for ($i = 1; $i <= 12; $i++) {
        $months[] = array('data' => $i, 'selected' => $i == $month);
    }

    $agentid = intval($_GPC['id']);
    $member = m('member')->getMember($agentid);
    $level1_agentids = p('commission')->getCommissionTeam($member['openid'], 1, 0, null,true);
    $prtimeStr = date('Y-m');
    $prtimeUnix = strtotime($prtimeStr);
    $prtoday = strtotime(date("Y-m-d"));
    $data = p('commission') -> agentChart($level1_agentids,$prtimeUnix,$prtoday);

    if($_GPC['search'] == 1){
        $timeStr1 = $year.'-'.$month;
        $timeUnix1 = strtotime($timeStr1);
        $month2 = $_GPC['month'] + 1;
        $timeStr2 = $year.'-'.$month2;
        $timeUnix2 = strtotime($timeStr2)-1;
        $nowTime = time();
        $data = array();
        $data2 = array();
        if($timeUnix1 <= $nowTime && $nowTime <= $timeUnix2){
            $timeUnix1 = strtotime($timeStr1);
            $yesterday = strtotime(date("Y-m-d",strtotime("-1 day")));
            $today = strtotime(date("Y-m-d"));

            $data = p('commission') -> agentChart($level1_agentids,$timeUnix1,$today);
        }else{
            $timeUnix3 = $timeUnix2 + 1;
            $data = p('commission') -> agentChart($level1_agentids,$timeUnix1,$timeUnix3);
        }

    }

    unset($tmp);
    $biaozhun1 = $member['windingstandard'];
    $charttitle = '粉丝统计图';
    unset($row);
    load()->func('tpl');
    include $this->template('agent_user_chart');
    die;







